<?php
$entryId = isset($_POST["entryId"]) ? $_POST["entryId"] : null;
$status = isset($_POST["status"]) ? $_POST["status"] : null;

$query = "SELECT id, created, content
		  FROM blogComments
		  WHERE entryId = '$entryId'";
if (strlen($status)) {
	$query .= "AND status = '$status' ";
}
$query .= "ORDER BY created DESC";

if (!$res1 = $db->runQuery($query)) {
	$data = "Error de MySQL: ".$db->getErrorDescription();
} else {
	if (!$db->getRowCount($res1)) {
		$data = "No hay datos que mostrar.";
	} else {
		$data = array();
		while ($row1 = $db->getRow($res1)) {
			$data[] = array(
				"id" => $row1["id"],
				"created" => $row1["created"],
				"content" => substr(utf8_encode($row1["content"]), 0, 30)."...",
				"editUrl" => Utils::generateSEOUrl($lang, "blogcomments", "edit", $row1["id"])
			);
		}
	}
}

$content->assign("status", $content->langmsg["blogCommentStatus"][$status]);
$content->assign("data", $data);
echo $content->fetch("blogcomments-table.tpl");
exit;
?>
